package com.emip.bean;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.codehaus.jackson.annotate.JsonIgnore;

import com.emip.util.ReportFormat;



@Entity
@Table(name = "T_SECONDSTORE")
public class SecondStoreBean implements Store, Serializable {
	
	
	private static final long serialVersionUID = 1L;

	@Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE,generator="S_SECOND_ID_GENE")
    @SequenceGenerator(name="S_SECOND_ID_GENE",sequenceName="S_SECOND_ID", allocationSize = 1)
	private int id;
	
	@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
    @JoinColumn(name = "siteID")
	private SiteBean site;
	@ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
    @JoinColumn(name = "itemID")
	private ItemBean item;
	@Column(name="value")
	private String value ;
	@Column(name="genTime")
	private Date genTime;
	@Column(name="flag")
	private String flag;
	@Column(name="filterFlag")
	private String filterFlag;
	@Column(name="oriValue")
	private String oriValue;
	
	public SecondStoreBean() {}
	
	public void setId(int id) {
		this.id = id;
	}
	public int getId() {
		return this.id;
	}
	public SiteBean getSite() {
		return site;
	}
	public void setSite(SiteBean site) {
		this.site = site;
	}
	
	@JsonIgnore
	public String getSiteID() {
		return this.site.getId();
	}
	
	@JsonIgnore
	public String getItemID() {
		return item.getId();
	}
	public ItemBean getItem() {
		return item;
	}
	public void setItem(ItemBean item) {
		this.item = item;
	}

	public void setValue(String value) {
		this.value = value;
	}
	public String getValue() {
		return this.value;
	}
	public void setGenTime(Date genTime) {
		this.genTime = genTime;
	}
	public Date getGenTime() {
		return this.genTime;
	}
	public void setFlag(String flag) {
		this.flag = flag;
	}
	public String getFlag() {
		return this.flag;
	}
	public void setFilterFlag(String filterFlag) {
		this.filterFlag = filterFlag;
	}
	public String getFilterFlag() {
		return this.filterFlag;
	}

	public String getOriValue() {
		return oriValue;
	}

	public void setOriValue(String oriValue) {
		this.oriValue = oriValue;
	}

	@JsonIgnore
	public String getTimeLabel() {
		return ReportFormat.getSecondFormat(genTime);
	}
}
